home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / t_os / diskdup / ddupgui.c next >
Text File  |  1993-07-08  |  12KB  |  539 lines

  1. /********************************************************************
  2.  *                                                                    *
  3.  *                            DISKDUP                            *
  4.  *                                                                    *
  5.  *                        オンメモリ型 DISKCOPY                        *
  6.  *                                                                    *
  7.  *                            diskdup.exp                                *
  8.  *                                                                    *
  9.  *                            for FM-TOWNS                            *
  10.  *                                                                    *
  11.  *            Copyright (c) ちにゃと & Tymic 1992. 1993.        *
  12.  *                                                                    *
  13.  *                            GUI ソース                            *
  14.  *                                                                    *
  15.  ********************************************************************/
  16.  
  17. #define    __GUISUB__                /* ファイル ID */
  18.  
  19. /********************************************************************
  20.     インクルードファイル
  21. *********************************************************************/
  22.  
  23. /* HI-C ライブラリ ヘッダー */
  24. #include <string.h>
  25.  
  26. /* T-BIOS C ライブラリ ヘッダー */
  27. #include <egb.h>
  28. #include <mos.h>
  29.  
  30. /* ソース ヘッダー */
  31. #include "diskdup.h"
  32. #include "ddupgui.h"
  33. #include "option.h"
  34.  
  35. /********************************************************************
  36.     変数
  37. *********************************************************************/
  38.  
  39. char str[60];                    /* 表示文字列 バッファ */
  40. extern int flagerr,flagipt;
  41. static char work[1536];            /* EGB 関数用 ワーク */
  42. static char para[64];            /* EGB 関数用 パラメータ バッファ */
  43. static char mwork[4096];        /* MOS 関数用 ワーク */
  44. static int sx, sy, ex, ey;        /* X Y 座標 グローバル バッファ */
  45.  
  46. static char pattern[ 2 + 4*16*16/8 + 16*16/8 ] = {    /* マウスパタ-ン設定 */
  47.     2,16,
  48.     0x88,0x88,0x88,0x88,0x88,0x08,0x00,0x00,    /* 1 */
  49.     0xf8,0xff,0xff,0xff,0xff,0x08,0x00,0x00,    /* 2 */
  50.     0xf8,0xff,0xff,0xff,0x8f,0x00,0x00,0x00,    /* 3 */
  51.     0xf8,0xff,0xff,0xff,0x08,0x00,0x00,0x00,    /* 4 */
  52.     0xf8,0xff,0xff,0x8f,0x00,0x00,0x00,0x00,    /* 5 */
  53.     0xf8,0xff,0xff,0xff,0x08,0x00,0x00,0x00,    /* 6 */
  54.     0xf8,0xff,0xff,0xff,0x8f,0x00,0x00,0x00,    /* 7 */
  55.     0xf8,0xff,0xf8,0xff,0xff,0x08,0x00,0x00,    /* 8 */
  56.     0xf8,0x8f,0x80,0xff,0xff,0x8f,0x00,0x00,    /* 9 */
  57.     0xf8,0x08,0x00,0xf8,0xff,0xff,0x08,0x00,    /* A */
  58.     0x88,0x00,0x00,0x80,0xff,0xff,0x8f,0x00,    /* B */
  59.     0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x08,    /* C */
  60.     0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x8f,    /* D */
  61.     0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x08,    /* E */
  62.     0x00,0x00,0x00,0x00,0x00,0x80,0x8f,0x00,    /* F */
  63.     0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,    /* 10 */
  64.     0x00,0x1f,    /* 1 */
  65.     0x00,0x1f,    /* 2 */
  66.     0x00,0x3f,    /* 3 */
  67.     0x00,0x7f,    /* 4 */
  68.     0x00,0xff,    /* 5 */
  69.     0x00,0x7f,    /* 6 */
  70.     0x00,0x3f,    /* 7 */
  71.     0x00,0x1f,    /* 8 */
  72.     0x08,0x0f,    /* 9 */
  73.     0x1c,0x07,    /* A */
  74.     0x3e,0x03,    /* B */
  75.     0x7f,0x01,    /* C */
  76.     0xff,0x80,    /* D */
  77.     0xff,0xc1,    /* E */
  78.     0xff,0xe3,    /* F */
  79.     0xff,0xf7     /* 10 */
  80. };
  81.  
  82.  
  83. /************************************************************************
  84. 【スクリ-ン設定】
  85.  
  86.         概要    
  87.         用法    
  88.         引数    
  89.         戻り値    
  90.         注意    
  91. ************************************************************************/
  92.  
  93. void setscreen( void )
  94. {
  95.     EGB_resolution( work, 0, 0x43 );    /* 0x4* はパレットを初期化しない */
  96.     EGB_resolution( work, 1, 0x43 );
  97.     EGB_displayPage( work, 1, 3 );        /* 画面設定 */
  98.     EGB_writePage( work, 1 );
  99. }
  100.  
  101.  
  102. /************************************************************************
  103. 【タイトルおよびメッセ-ジ用矩形表示】
  104.  
  105.         概要    
  106.         用法    putworkbox();
  107.         引数    
  108.         戻り値    
  109.         注意    
  110. ************************************************************************/
  111.  
  112. void putworkbox( void )
  113. {
  114.     EGB_writeMode( work, 0 );
  115.     EGB_paintMode( work, 0x22 );
  116.     EGB_pen( work, 0 );
  117.     EGB_color( work, 0, 8 );
  118.     EGB_color( work, 1, 15 );
  119.     EGB_color( work, 2, 15 );
  120.     EGB_penSize( work, 1 );
  121.  
  122.     sx = SSX;
  123.     sy = SSY;
  124.     ex = EEX;
  125.     ey = EEY;
  126.     box();                /* 外枠をかく */
  127.  
  128.     EGB_textZoom( work, 0, 16, 16 );
  129.     EGB_textZoom( work, 1, 16, 16 );
  130.     EGB_textSpace( work, 3 );
  131.     EGB_fontStyle( work, 0x01 );
  132.     EGB_textDisplayDirection( work, 0 );
  133.     EGB_textDirection( work, 0 );
  134.     EGB_color( work, 0, 8 );
  135.  
  136.     sx = SSX + 44;
  137.     sy = SSY + 24;
  138.     strcpy( str, Title1 );
  139.     putwd();            /* ソフト名を表示 */
  140.  
  141.     EGB_writeMode( work, 0 );
  142.     EGB_textZoom( work, 0, 6, 12 );
  143.     EGB_textZoom( work, 1, 12, 12 );
  144.     EGB_textSpace( work, 1 );
  145.     EGB_fontStyle( work, 0 );
  146.     EGB_color( work, 0, 8 );
  147.     EGB_color( work, 1, 15 );
  148.     EGB_color( work, 2, 15 );
  149.  
  150.     sx = SSX + 40;
  151.     sy = SSY + 48;
  152.     strcpy( str, Title2 );
  153.     putwd();
  154. }
  155.  
  156.  
  157. /************************************************************************
  158. 【選択】
  159.  
  160.         概要    
  161.         用法    select();
  162.         引数    無し
  163.         戻り値    int        -1                : 実行選択
  164.                         1                : 取消選択
  165.         注意    
  166. ************************************************************************/
  167.  
  168. int    select(    void )
  169. {
  170.     int        fg,
  171.             sel,
  172.             ch, x, y,
  173.             button,
  174.             bcount;
  175.  
  176.   if ( (flagipt==0) || (flagerr==1 ) )
  177.   {
  178.     sx = EEX - 203;
  179.     sy = EEY - 23;
  180.     ex = EEX - 148;
  181.     ey = EEY - 2;
  182.     box();                /* 『実行』と『取消』用の枠をかく。*/
  183.  
  184.     sx = EEX - 200;
  185.     sy = EEY - 20;
  186.     ex = EEX - 151;
  187.     ey = EEY - 5;
  188.     box();                /* 同上 */
  189.  
  190.     sx = EEX - 100;
  191.     sy = EEY - 20;
  192.     ex = EEX - 51;
  193.     ey = EEY - 5;
  194.     box();                /* 同上 */
  195.  
  196.     EGB_fontStyle( work, 0x00 );
  197.     EGB_textZoom( work, 1, 12, 12 );
  198.  
  199.     sx = EEX - 190;
  200.     sy = EEY - 7;
  201.     strcpy( str, "実行" );
  202.     putwd();            /* 『実行』を表示 */
  203.  
  204.     sx = EEX - 90;
  205.     sy = EEY - 7;
  206.     strcpy( str, "取消" );
  207.     putwd();            /* 『取消』を表示 */
  208.  
  209.     MOS_start( mwork, 4096 );
  210.     MOS_writePage( 1 );
  211.     MOS_resolution( 1, 3 );
  212.     MOS_type( 2, 0, 0, pattern );
  213.  
  214.     EGB_writeMode( work, 4 );
  215.     EGB_color( work, 0, 7 );
  216.     EGB_color( work, 1, 7 );
  217.     EGB_color( work, 2, 7 );
  218.  
  219.     MOS_setpos( EEX - 162, EEY - 13 );
  220.     MOS_disp( 1 );        /* マウス開始 */
  221.  
  222.     fg = 0;
  223.     sel = 0;
  224.     do {
  225.         do {
  226.             MOS_rdpos( &ch, &x, &y );
  227.         } while ( ch != 1 );
  228.  
  229.         if ( y >= (EEY - 23) && y <= (EEY - 5) ) {
  230.             if ( x > (EEX - 201) && x < (EEX - 150) && fg == 0 ) {
  231.                 MOS_disp( 0 );
  232.                 sx = EEX - 203;
  233.                 sy = EEY - 23;
  234.                 ex = EEX - 148;
  235.                 ey = EEY - 2;
  236.                 box();            /* 『実行』の枠内の反転表示 */
  237.                 MOS_disp( 1 );
  238.                 fg = 1;
  239.                 sel = -1;
  240.             }
  241.             else {
  242.                 if ( x > (EEX - 101) && x < (EEX - 51) && fg == 0 ) {
  243.                     MOS_disp( 0 );
  244.                     sx = EEX - 100;
  245.                     sy = EEY - 20;
  246.                     ex = EEX - 51;
  247.                     ey = EEY - 5;
  248.                     box();            /* 『取消』の枠内の反転表示 */
  249.                     MOS_disp( 1 );
  250.                     fg = 2;
  251.                     sel = 1;
  252.                 }
  253.                 else {
  254.                     fg = 0;
  255.                 }
  256.             }
  257.         }
  258.         if ( fg == 1 ) {
  259.             do {
  260.                 MOS_rdopen( 0, &button, &bcount, &x, &y );
  261.               } while ( button == 1 );
  262.             MOS_disp( 0 );
  263.             sx = EEX - 203;
  264.             sy = EEY - 23;
  265.             ex = EEX - 148;
  266.             ey = EEY - 2;
  267.             box();            /* 『実行』の反転表示を元に戻す。 */
  268.             MOS_disp( 1 );
  269.             fg = 0;
  270.         }
  271.     } while ( sel == 0 );
  272.  
  273.     MOS_end();
  274.     return sel;
  275.   }
  276.   else
  277.   {
  278.   return -1;
  279.   }
  280. }
  281.  
  282.  
  283. /************************************************************************
  284. 【確認】
  285.  
  286.         概要    
  287.         用法    ready();
  288.         引数    無し
  289.         戻り値    無し
  290.         注意    
  291. ************************************************************************/
  292.  
  293. void ready( void )
  294. {
  295.   if ( (flagipt==0) || (flagerr==1 ) )
  296.   {
  297.     int        fg,
  298.             sel,
  299.             ch, x, y,
  300.             button,
  301.             bcount;
  302.  
  303.     EGB_writeMode( work, 0 );
  304.     EGB_color( work, 0, 15 );
  305.     EGB_color( work, 1, 15 );
  306.     EGB_color( work, 2, 15 );
  307.     sx = EEX - 210;
  308.     sy = EEY - 23;
  309.     ex = EEX - 1;
  310.     ey = EEY - 1;
  311.     box();
  312.  
  313.     EGB_color( work, 0, 8 );
  314.     EGB_penSize( work, 1 );
  315.     sx = EEX - 100;
  316.     sy = EEY - 20;
  317.     ex = EEX - 51;
  318.     ey = EEY - 5;
  319.     box();
  320.  
  321.     EGB_fontStyle( work, 0x00 );
  322.     EGB_textZoom( work, 1, 12, 12 );
  323.  
  324.     sx = EEX - 90;
  325.     sy = EEY - 7;
  326.     strcpy( str, "確認" );
  327.     putwd();
  328.  
  329.     EGB_writeMode( work, 0 );
  330.     EGB_color( work, 0, 8 );
  331.  
  332.     MOS_start( mwork, 4096 );
  333.     MOS_writePage( 1 );
  334.     MOS_resolution( 1, 3 );
  335.     MOS_type( 2, 0, 0, pattern );
  336.  
  337.     EGB_writeMode( work, 4 );
  338.     EGB_color( work, 0, 7 );
  339.     EGB_color( work, 1, 7 );
  340.     EGB_color( work, 2, 7 );
  341.  
  342.     MOS_setpos( EEX - 62, EEY - 13 );
  343.     MOS_disp( 1 );        /* マウス開始 */
  344.  
  345.     fg = 0;
  346.     sel = 0;
  347.     do {
  348.         do {
  349.             MOS_rdpos( &ch, &x, &y );
  350.         } while    ( ch !=    1 );
  351.  
  352.         if ( y >= (EEY - 23) && y <= (EEY - 5) ) {
  353.             if ( x > (EEX - 101) && x < (EEX - 51) && fg == 0 ) {
  354.                 MOS_disp( 0 );
  355.                 sx = EEX - 100;
  356.                 sy = EEY - 20;
  357.                 ex = EEX - 51;
  358.                 ey = EEY - 5;
  359.                 box();            /* 『確認』の枠内の反転表示 */
  360.                 MOS_disp( 1 );
  361.                 fg = 1;
  362.                 sel = -1;
  363.             }
  364.         }
  365.  
  366.         if ( fg == 1 ) {
  367.             do {
  368.                 MOS_rdopen( 0, &button, &bcount, &x, &y );
  369.             } while ( button == 1 );
  370.             MOS_disp( 0 );
  371.             sx = EEX - 100;
  372.             sy = EEY - 20;
  373.             ex = EEX - 51;
  374.             ey = EEY - 5;
  375.             box();                /* 『実行』の反転表示を元に戻す。 */
  376.             MOS_disp( 1 );
  377.             fg = 0;
  378.             sel = -1;
  379.         }
  380.     } while ( sel == 0 );
  381.     MOS_end();
  382.   }
  383. }
  384.  
  385.  
  386. /************************************************************************
  387. 【中塗り矩形枠描画】
  388.  
  389.         概要    塗り潰された矩形をかく。。
  390.         用法    box();
  391.         引数    無し
  392.         戻り値    無し
  393.         注意    sx, sy, ex, ey 始点と終点の X, Y 座標
  394. ************************************************************************/
  395.  
  396. void box( void )
  397. {
  398.     WORD(para+0) = sx;   /* sx */
  399.     WORD(para+2) = sy;   /* sy */
  400.     WORD(para+4) = ex;   /* ex */
  401.     WORD(para+6) = ey;   /* ey */
  402.     EGB_rectangle( work, para );
  403. }
  404.  
  405.  
  406. /************************************************************************
  407. 【文字列出力】
  408.  
  409.         概要    文字列を出力する。
  410.         用法    putmessage();
  411.         引数    無し
  412.         戻り値    無し
  413.         注意    str に入っている文字列を出力
  414.                 表示文字列は '\0' で終了していること
  415. ************************************************************************/
  416.  
  417. void putmessage( void )
  418. {
  419.   if ( (flagipt==0) || (flagerr==1 ) )
  420.   {
  421.     int        j;
  422.     char    tmpbuf[60];
  423.  
  424.     EGB_writeMode( work, 0 );
  425.     EGB_color( work, 0,    15 );
  426.     EGB_color( work, 1,    15 );
  427.     EGB_color( work, 2,    15 );
  428.  
  429.     sx = SSX + 20;
  430.     sy = SSY + 49;
  431.     ex = EEX - 1;
  432.     ey = EEY - 24;
  433.     box();
  434.  
  435.     EGB_writeMode( work, 0);
  436.     EGB_color( work, 0, 8 );
  437.     EGB_color( work, 1, 15 );
  438.     EGB_color( work, 2, 15 );
  439.     sx = SSX + 20;
  440.     sy = SSY + 72;
  441.  
  442.     if ( ( j = strlen( str ) ) > 56 ) {
  443.         str[56] = 0;
  444.     }
  445.     else {
  446.         /* 文字列 センタリング */
  447.         if ( ( j = ( 56 - j ) / 2 ) != 0 ) {
  448.             strcpy( tmpbuf, str );
  449.             memset( str, ' ', j );
  450.             strcpy( str + j, tmpbuf );
  451.         }
  452.     }
  453.  
  454.     putwd();
  455.   }
  456. }
  457.  
  458. /************************************************************************
  459. 【文字列出力】
  460.  
  461.         概要    文字列を出力する。
  462.         用法    putwd();
  463.         引数    無し
  464.         戻り値    無し
  465.         注意
  466. ************************************************************************/
  467.  
  468. void putwd( void )
  469. {
  470.     int        i,
  471.             wdlong;
  472.  
  473.     wdlong = strlen( str );
  474.  
  475.     WORD(para+0) = sx;
  476.     WORD(para+2) = sy;
  477.     WORD(para+4) = wdlong;
  478.  
  479.     for ( i = 0; i < wdlong; i++ ) {
  480.         WORD(para + 6 + i) = str[i];
  481.     }
  482.  
  483.     EGB_sjisString( work, para );
  484. }
  485.  
  486.  
  487. /************************************************************************
  488. 【文字列消去】
  489.  
  490.         概要    文字列を消去する。
  491.         用法    clrmessage();
  492.         引数    無し 
  493.         戻り値    無し
  494.         注意
  495. ************************************************************************/
  496.  
  497. void clrmessage( void )
  498. {
  499.     EGB_writeMode( work, 0 );
  500.     EGB_color( work, 0, 15 );
  501.     EGB_color( work, 1, 15 );
  502.     EGB_color( work, 2, 15 );
  503.  
  504.     sx = SSX + 20;
  505.     sy = SSY + 49;
  506.     ex = EEX - 1;
  507.     ey = EEY - 1;
  508.     box();
  509.  
  510.     EGB_writeMode( work, 0 );
  511.     EGB_color( work, 0, 8 );
  512.     EGB_color( work, 1, 15 );
  513.     EGB_color( work, 2, 15 );
  514. }
  515.  
  516.  
  517. /************************************************************************
  518. 【エラー文字列出力】
  519.  
  520.         概要    エラー 文字列を出力する。
  521.         用法    ErrMsgPutWord( errnum );
  522.         引数    int        errnum            : エラー 文字列番号
  523.         戻り値    無し
  524.         注意    無し
  525. ************************************************************************/
  526.  
  527. void ErrMsgPutWord(    int    errnum )
  528. {
  529.     /* エラー 文字列出力 */
  530.     flagerr=1;
  531.     strcpy(    str, ErrMsgTbl[errnum] );
  532.     putmessage();
  533.     ready();
  534.     flagerr=0;
  535. }
  536.  
  537.  
  538. /* end of file */
  539.